home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chtsht / dcsstart.dht < prev    next >
Encoding:
Text File  |  1996-06-25  |  11.6 KB  |  368 lines

  1. The Delphi Cheat Sheet
  2.  
  3. <IMG "DELLOGO.BMP">
  4.  
  5. A compilation of online tips, tricks, techniques, workarounds, 
  6. and hacks for Delphi 1.0  and Delphi 2.0.
  7.  
  8. Click on a letter below to move to that section of the index. 
  9. Then click on the title of the tip you wish to examine.
  10.  
  11. To bring up the floating toolbar, right click anywhere not
  12. show the hand cursor.
  13.  
  14. This file is an example taken from the larger and continually updated files at
  15. www.tde.com/ciupkc/cheatsht.html. Please feel free to drop by for a look!
  16.  
  17. Enjoy!
  18.  
  19. <A NAME="TheTop">Alphabetical Topic List</A>
  20.  
  21. <A HREF="#IndexA">A </A> <A HREF="#IndexB">B </A> <A HREF="#IndexC">C </A><A HREF="#IndexD">D </A> <A HREF="#IndexE">E </A> 
  22. <A HREF="#IndexF">F </A><A HREF="#IndexG">G </A> <A HREF="#IndexH">H </A> <A HREF="#IndexI">I </A> <A HREF="#IndexJ">J </A> 
  23. <A HREF="#IndexK">K </A> <A HREF="#IndexL">L </A><A HREF="#IndexM">M </A> <A HREF="#IndexN">N </A> <A HREF="#IndexO">O </A>
  24. <A HREF="#IndexP">P </A> <A HREF="#IndexQ">Q </A> <A HREF="#IndexR">R </A><A HREF="#IndexS">S </A> <A HREF="#IndexT">T </A> 
  25. <A HREF="#IndexU">U </A><A HREF="#IndexV">V </A> <A HREF="#IndexW">W </A> <A HREF="#IndexX">X </A> <A HREF="#IndexY">Y </A> 
  26. <A HREF="#IndexZ">Z </A>
  27.  
  28. <A NAME="IndexA">Section A</A>
  29.  
  30. <A HREF="#Ampersand">Ampersand Enabling In TLabel</A>
  31.  
  32. <A NAME="IndexB">Section B</A>
  33.  
  34. <A HREF="#Blocks">Persistent Block Marking</A>
  35.  
  36. <A NAME="IndexC">Section C</A>
  37.  
  38. <A HREF="#Colors">Using RGB Colors With TColor</A>
  39.  
  40. <A NAME="IndexD">Section D</A>
  41.  
  42. <A HREF="#DCRBug">DCR Uppercase Name Bug</A>
  43.  
  44. <A NAME="IndexE">Section E</A>
  45.  
  46. <A HREF="#Errors">Turning Off Exception Handling in the IDE</A>
  47.  
  48. <A NAME="IndexF">Section F</A>
  49.  
  50. <A HREF="#FMXUCopyBug">FileCopy Bug</A>
  51.  
  52. <A NAME="IndexG">Section G</A>
  53.  
  54. <A HREF="#GraphicsDrawBug">Position Bug in TCanvas.Draw</A>
  55.  
  56. <A NAME="IndexH">Section H</A>
  57.  
  58. <A HREF="#HWLIB">Hardwired \LIB in VCL Path</A>
  59.  
  60. <A NAME="IndexI">Section I</A>
  61.  
  62. <A HREF="#BigImage">Image Loading Failures</A>
  63.  
  64. <A NAME="IndexJ">Section J</A>
  65.  
  66. <A HREF="#Justification">Vertical Label Text Justification</A>
  67.  
  68. <A NAME="IndexK">Section K</A>
  69.  
  70. <A HREF="#Keypress">Trapping Keypresses</A>
  71.  
  72. <A NAME="IndexL">Section L</A>
  73.  
  74. <A HREF="#FListboxBug">FileListbox Count Bug</A>
  75.  
  76. <A NAME="IndexM">Section M</A>
  77.  
  78. <A HREF="#MultiImage">Displaying same bitmap in multiple images</A>
  79.  
  80. <A NAME="IndexN">Section N</A>
  81.  
  82. <A HREF="#NewError">Common Error Creating New Components</A>
  83.  
  84. <A NAME="IndexO">Section O</A>
  85.  
  86. <A HREF="#OrderShow">Controlling Order of display of Images</A>
  87.  
  88. <A NAME="IndexP">Section P</A>
  89.  
  90. <A HREF="#PaletteBug">Bug in TImage with 256 color palettes</A>
  91.  
  92. <A NAME="IndexQ">Section Q</A>
  93.  
  94. <A HREF="#QuickFlip">Quickly changing listbox contents</A>
  95.  
  96. <A NAME="IndexR">Section R</A>
  97.  
  98. <A HREF="#ResizeBug">Resize Bug in TCombobox</A>
  99.  
  100. <A NAME="IndexS">Section S</A>
  101.  
  102. <A HREF="#SymbolError">Avoiding "Error Loading Symbol File" message</A>
  103.  
  104. <A NAME="IndexT">Section T</A>
  105.  
  106. <A HREF="#Terminate">Resource-safe instant program termination</A>
  107.  
  108. <A NAME="IndexU">Section U</A>
  109.  
  110. <A HREF="#UnlimitedBMP">Loading Unlimited Size TBitmaps</A>
  111.  
  112. <A NAME="IndexV">Section V</A>
  113.  
  114. <A HREF="#VerSBRange">Controlling Vertical Scrollbox size at runtime</A>
  115.  
  116. <A NAME="IndexW">Section W</A>
  117.  
  118. <A HREF="#WorkPict">Using TPictureEditor to Work with TPictures in the IDE</A>
  119.  
  120. <A NAME="IndexX">Section X</A>
  121.  
  122. <A HREF="#XCopy">XCopy command</A>
  123.  
  124. <A NAME="IndexY">Section Y</A>
  125.  
  126. <A HREF="#YXOrder">X and Y coordinates common mistake</A>
  127.  
  128. <A NAME="IndexZ">Section Z</A>
  129.  
  130. <A HREF="#ZOrder">Controlling Z Order of Controls</A>
  131.  
  132. ===============================================================
  133.  
  134. <A NAME="Ampersand">Ampersand Enabling in TLabel</A>
  135.  
  136. To enable or disable the & character to become an underline,
  137. use the ShowAccelChar property. If true, the & becomes an
  138. underline. If false, it become the & character
  139.  
  140. <A HREF="#TheTop">Back To Top</A>
  141. ===============================================================
  142.  
  143. <A NAME="Blocks">Persistent Block Marking</A>
  144.  
  145. Use the OPTIONS|EDITOR "Persistent Blocks" checkbox for this one.
  146. (another annoying "feature"...)
  147.  
  148. <A HREF="#TheTop">Back To Top</A>
  149. ===============================================================
  150.  
  151. <A NAME="Colors">Using RGB Colors With TColor</A>
  152.  
  153. The TColor property will accept RGB colors output from Windows
  154. API calls.
  155.  
  156. <A HREF="#TheTop">Back To Top</A>
  157. ===============================================================
  158.  
  159. <A NAME="DCRBug">DCR Uppercase Name Bug</A>
  160.  
  161. You MUST put the name of your component in UPPERCASE in the DCR
  162. file or the IDE won't find it, regardless of capitalization in
  163. the PAS file.
  164.  
  165. <A HREF="#TheTop">Back To Top</A>
  166. ===============================================================
  167.  
  168. <A NAME="Errors">Turning Off Exception Handling in the IDE</A>
  169.  
  170. Use the OPTIONS|ENVIRONMENT "break on Exception" checkbox. (dratted
  171. nuisance if you don't happen to notice that sucker...)
  172.  
  173. <A HREF="#TheTop">Back To Top</A>
  174. ===============================================================
  175.  
  176. <A NAME="FMXUCopyBug">FileCopy Bug</A>
  177.  
  178. FMXU has a problem differentiating between files and directories.
  179. The FMXU elsewhere on this site doesn't.
  180.  
  181. <A HREF="#TheTop">Back To Top</A>
  182. ===============================================================
  183.  
  184. <A NAME="GraphicsDrawBug">Position Bug in TCanvas.Draw</A>
  185.  
  186. If you issue a Canvas.Draw( 0 , 0 , MyGraphic ) it will not always draw.
  187. Canvas.Draw( 1 , 1 , MyGraphic ) will always work.
  188.  
  189. <A HREF="#TheTop">Back To Top</A>
  190. ===============================================================
  191.  
  192. <A NAME="HWLIB">Hardwired \LIB in VCL Path</A>
  193.  
  194. In older versions of Delphi, the VCL path has a hardwired \LIB in it,
  195. which makes using other directories for components impossible. The fix is
  196. to upgrade to a newer version of Delphi.
  197.  
  198. <A HREF="#TheTop">Back To Top</A>
  199. ===============================================================
  200.  
  201. <A NAME="BigImage">Image Loading Failures</A>
  202.  
  203. The TImage component won't load images larger than 64K. Use the
  204. TUnlimitedImage component elsewhere on this site to overcome this.
  205.  
  206. <A HREF="#TheTop">Back To Top</A>
  207. ===============================================================
  208.  
  209. <A NAME="Justification">Vertical Label Text Justification</A>
  210.  
  211. The following code controls vertical label text justification:
  212.  
  213. Label1.Height := Label1.Canvas.TextHeight( Label1.Caption ) + 2;
  214.  
  215. <A HREF="#TheTop">Back To Top</A>
  216. ===============================================================
  217.  
  218. <A NAME="Keypress">Trapping Keypresses</A>
  219.  
  220. Use the FormKeyDown event of TForm to trap keypresses to a form,
  221. and ControlKeyDown to trap those to components.
  222.  
  223. <A HREF="#TheTop">Back To Top</A>
  224. ===============================================================
  225.  
  226. <A NAME="FListboxBug">FileListbox Count Bug</A>
  227.  
  228. The Count property of the FileListBox doesn't respond correctly
  229. at runtime. If you copy the Items to a stringlist, though, they
  230. are correctly counted.
  231.  
  232. <A HREF="#TheTop">Back To Top</A>
  233. ===============================================================
  234.  
  235. <A NAME="MultiImage">Displaying same bitmap in multiple images</A>
  236.  
  237. Use this code to switch TImage bitmaps instantly:
  238.  
  239. MyImage.Picture.Assign( TheOtherImage.Picture );
  240.  
  241. <A HREF="#TheTop">Back To Top</A>
  242. ===============================================================
  243.  
  244. <A NAME="NewError">Common Error Creating New Components</A>
  245.  
  246. Don't forget this is wrong:
  247.  
  248. MyNewComponent.Create( self );!!!
  249.  
  250. The correct syntax is:
  251.  
  252. MyNewComponent := TMyNewComponent.Create( Self );
  253.  
  254. otherwise you get a GPF!
  255.  
  256. <A HREF="#TheTop">Back To Top</A>
  257. ===============================================================
  258.  
  259. <A NAME="OrderShow">Controlling Order of display of Images</A>
  260.  
  261. You can control the display order of images by setting their ZOrder
  262. value via SendToFront and BringToBack methods.
  263.  
  264. <A HREF="#TheTop">Back To Top</A>
  265. ===============================================================
  266.  
  267. <A NAME="PaletteBug">Bug in TImage with 256 color palettes</A>
  268.  
  269. THIS IS A BIGGIE!!!!
  270.  
  271. The TImage does not set the Palette correctly, due to a failure
  272. to handle RealizePalette correctly. Fixes worked until the latest
  273. release, now they don't! New fixes are being researched...
  274.  
  275. <A HREF="#TheTop">Back To Top</A>
  276. ===============================================================
  277.  
  278. <A NAME="QuickFlip">Quickly changing listbox contents</A>
  279.  
  280. You can switch the contents of a listbox with the following 
  281. single line of code:
  282.  
  283. TheListbox.items.Assign( MyItemsStringList );
  284.  
  285. where MyItemsStringList is a stringlist. Note that the old contents
  286. are destroyed automatically and cannot be regained.
  287.  
  288. <A HREF="#TheTop">Back To Top</A>
  289. ===============================================================
  290.  
  291. <A NAME="ResizeBug">Resize Bug in TCombobox</A>
  292.  
  293. The TCombobox component, if resized at runtime, doesn't resize
  294. the windows-drawn portion of the display (ie the drop down box.)
  295. There is not a fix known at this time to the author.
  296.  
  297. <A HREF="#TheTop">Back To Top</A>
  298. ===============================================================
  299.  
  300. <A NAME="SymbolError">Avoiding "Error Loading Symbol File" message</A>
  301.  
  302. To avoid getting the ubiquitous "Error Loading Symbol File" message,
  303. simply don't copy the DSM, OPT, or DSK files with the code to a new
  304. directory.
  305.  
  306. <A HREF="#TheTop">Back To Top</A>
  307. ===============================================================
  308.  
  309. <A NAME="Terminate">Resource-safe instant program termination</A>
  310.  
  311. Use Application.Terminate for a fast, resource-safe way to halt a
  312. delphi EXE.
  313.  
  314. <A HREF="#TheTop">Back To Top</A>
  315. ===============================================================
  316.  
  317. <A NAME="UnlimitedBMP">Loading Unlimited Size TBitmaps</A>
  318.  
  319. A TBitmap won't accept a bitmap larger than 64K in Delphi 1.0. See
  320. How To Three of Chapter Six of Delphi Developers Solutions for a fix!
  321.  
  322. <A HREF="#TheTop">Back To Top</A>
  323. ===============================================================
  324.  
  325. <A NAME="VerSBRange">Controlling Vertical Scrollbox size at runtime</A>
  326.  
  327. By setting the Range property of a scrollbox, you automatically change the
  328. size and existence of the vertical scrollbar.
  329.  
  330. <A HREF="#TheTop">Back To Top</A>
  331. ===============================================================
  332.  
  333. <A NAME="WorkPict">Using TPictureEditor to Work with TPictures in the IDE</A>
  334.  
  335. You can use the TPictureEditor class as a property editor for TPicture components
  336. you write yourself for the IDE. It works identically to the Picture property of
  337. TImage components.
  338.  
  339. <A HREF="#TheTop">Back To Top</A>
  340. ===============================================================
  341.  
  342. <A NAME="XCopy">XCopy command</A>
  343.  
  344. This isn't Delphi, but it's really neat! it copies directories recursively,
  345. and even sets the READONLY flag as a default (perfect for copying the RFC
  346. files from the CD!)
  347.  
  348. <A HREF="#TheTop">Back To Top</A>
  349. ===============================================================
  350.  
  351. <A NAME="YXOrder">X and Y coordinates common mistake</A>
  352.  
  353. It is easy to confuse Height and Width, Top and Left. Always remember
  354. that Height and Top are Y coordinates and Left and Width are X coordinates.
  355.  
  356. <A HREF="#TheTop">Back To Top</A>
  357. ===============================================================
  358.  
  359. <A NAME="ZOrder">Controlling Z Order of Controls</A>
  360.  
  361. You can use the "bringtofront" and "sendtoback" methods of all controls and TForms
  362. to move them into view when hidden by other controls. (Note that this method does
  363. not work between non windows and windows controls; ie, a non windowed control will
  364. always draw BEHIND a windowed one.
  365.  
  366. <A HREF="#TheTop">Back To Top</A>
  367. ===============================================================
  368.